﻿@using BV.PACS.WEB.Shared.Models
@using BV.PACS.WEB.Client.Services.Api
@using BV.PACS.WEB.Client.Shared.Components
@inherits BV.PACS.WEB.Client.Shared.Base.Catalog<BV.PACS.WEB.Shared.Models.SourceCatalogDto, BV.PACS.WEB.Client.I18nText.SourceCatalog>

<h1>@Translations.Caption</h1>

<div class="row">
    <div class="@PageContext.SearchPanelCssClass" >
        <SourceSearchPanel 
                           OnSearch=@OnSearchPanelSearch
                           Condition =@PageContext.Condition>

        </SourceSearchPanel>
    </div>

    <div class="@PageContext.GridPanelCssClass" >
        <div class="row">

            <div class="col-sm-12">
                <button @onclick="@OnSearchPanelToggle" class="btn btn-primary float-right" style="margin-bottom: 16px;">@PacsMessagesTranslations[PageContext.ShowHideSearchPanelCaption]</button>
            </div>
            <div class="col-sm-12">
                <DxFormLayout CaptionPosition="@CaptionPosition.Vertical">
                    <DxFormLayoutItem ColSpanLg="12" ColSpanMd="12">
                        <Template Context="GridContext">
                            <DxDataGrid Data="@DataSource"
                                        ShowFilterRow="@false"
                                        ShowPager="@false"
                                        AllowDataRowSelection="@false"
                                        PageSize="@PageContext.Condition.PageSize">

                                <DxDataGridColumn Field="@nameof(SourceCatalogDto.SourceBarcode)" Caption="@Translations.SourceBarcode">
                                    <DisplayTemplate>
                                        <SourceBarcodeCell Context="@context"
                                                           OnCellClick="@OnSelectItem">

                                        </SourceBarcodeCell>
                                    </DisplayTemplate>
                                </DxDataGridColumn>

                                <DxDataGridColumn Field="@nameof(SourceCatalogDto.SourceTemplateName)" Caption="@Translations.SourceTemplateName">
                                </DxDataGridColumn>

                                <DxDataGridDateEditColumn Field="@nameof(SourceCatalogDto.SourceCreationDate)" Caption="@Translations.SourceCreationDate">
                                </DxDataGridDateEditColumn>

                                <DxDataGridColumn Field="@nameof(SourceCatalogDto.SourceType)" Caption="@Translations.SourceType">
                                </DxDataGridColumn>

                                <DxDataGridColumn Field="@nameof(SourceCatalogDto.SourcePointOfOrigin)" Caption="@Translations.SourcePointOfOrigin">
                                </DxDataGridColumn>

                                <DxDataGridColumn Field="@nameof(SourceCatalogDto.MaterialsAndAliquotsCount)" Caption="@Translations.MaterialsAndAliquotsCount">
                                </DxDataGridColumn>
                            </DxDataGrid>
                            @if (PageCount > 1)
                            {
                                <DxPager PageCount=@PageCount
                                         @bind-ActivePageIndex=@ActivePageNumber
                                         CollapseButtonCount=@BaseSettings.CollapseButtonCount>
                                </DxPager>
                            }
                        </Template>
                    </DxFormLayoutItem>
                </DxFormLayout>
            </div>
        </div>
    </div>
</div>
